#include<stdlib.h>
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/mman.h>
#include<signal.h>

void sighanler(int sig){
    printf(" pid = %d 收到信号：%d  \n",getpid(),sig);
    exit(0);
    
}
int main(int argc,char **argv){


   int fp = open("a.txt",O_RDWR|O_CREAT,0644);
   if(fp == -1){
    perror("file open is error");
    exit(0);
   }
   ftruncate(fp,4096);
   char * ptr = (char *)mmap(NULL,4096,PROT_WRITE|PROT_READ,MAP_SHARED,fp,0);
   if(ptr == MAP_FAILED){
    perror("mmap is error");
    exit(0);
   };
   printf(" %s \n",ptr);
   munmap(ptr ,4096);
   close(fp);
   




   

   return 0;
}